From: Joey Hess Date: Mon, 29 Sep 2025 15:06:18 +0000 (-0400) Subject: don't set locale encoding when opening binary file X-Git-Tag: archive/raspbian/10.20251029-1+rpi1~1^2~3^2~51 X-Git-Url: https://dgit.raspbian.org/%22http:/www.example.com/cgi/%22https://%22Program/%22http:/www.example.com/cgi/%22https:/%22Program?a=commitdiff_plain;h=026bab0c4963e3b26ed4e2ad2694a45c92c85f6f;p=git-annex.git don't set locale encoding when opening binary file importfeed: Fix encoding issues parsing feeds when built with OsPath. --- diff --git a/CHANGELOG b/CHANGELOG index d61836f7c7..aa63a40a0e 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -4,6 +4,7 @@ git-annex (10.20250926) UNRELEASED; urgency=medium annex+http urls and git-annex p2phttp. * enableremote: Allow type= to be provided when it does not change the type of the special remote. + * importfeed: Fix encoding issues parsing feeds when built with OsPath. -- Joey Hess Thu, 25 Sep 2025 13:36:21 -0400 diff --git a/Utility/FileIO/CloseOnExec.hs b/Utility/FileIO/CloseOnExec.hs index 3d1bb739f7..1a91add1e7 100644 --- a/Utility/FileIO/CloseOnExec.hs +++ b/Utility/FileIO/CloseOnExec.hs @@ -3,9 +3,9 @@ - All functions have been modified to set the close-on-exec - flag to True. - - - Also, functions that return a Handle have been modified to - - use the locale encoding, working around this bug: - - https://github.com/haskell/file-io/issues/45 + - Also, functions that return a Handle (for a non-binary file) + - have been modified to use the locale encoding, working around + - this bug: https://github.com/haskell/file-io/issues/45 - - Copyright 2025 Joey Hess - Copyright 2024 Julian Ospald @@ -70,12 +70,12 @@ openFile osfp iomode = augmentError "openFile" osfp $ withBinaryFile :: OsPath -> IOMode -> (Handle -> IO r) -> IO r withBinaryFile osfp iomode act = (augmentError "withBinaryFile" osfp - $ withOpenFileEncoding osfp iomode True False closeOnExec (try . act) True) + $ withOpenFile' osfp iomode True False closeOnExec (try . act) True) >>= either ioError pure openBinaryFile :: OsPath -> IOMode -> IO Handle openBinaryFile osfp iomode = augmentError "openBinaryFile" osfp $ - withOpenFileEncoding osfp iomode True False closeOnExec pure False + withOpenFile' osfp iomode True False closeOnExec pure False readFile :: OsPath -> IO BSL.ByteString readFile fp = withFileNoEncoding' fp ReadMode BSL.hGetContents diff --git a/doc/bugs/importfeed__58___Enum.toEnum__123__Word8__125____58___tag___40__8217__41___is_outs.mdwn b/doc/bugs/importfeed__58___Enum.toEnum__123__Word8__125____58___tag___40__8217__41___is_outs.mdwn index a0ab387188..e6ee11eb86 100644 --- a/doc/bugs/importfeed__58___Enum.toEnum__123__Word8__125____58___tag___40__8217__41___is_outs.mdwn +++ b/doc/bugs/importfeed__58___Enum.toEnum__123__Word8__125____58___tag___40__8217__41___is_outs.mdwn @@ -96,3 +96,5 @@ And it seems a fairly recent breakage, as IIRC the previous installed was from 2 ### Have you had any luck using git-annex before? (Sometimes we get tired of reading bug reports all day and a lil' positive end note does wonders) Yes, for many years. git-annex has worked vey well for downloading/collecting podcasts for years, which is why t was surprising it's suddenly failing like this. + +> [[fixed|done]] --[[Joey]] diff --git a/doc/bugs/importfeed__58___Enum.toEnum__123__Word8__125____58___tag___40__8217__41___is_outs/comment_6_9c6851e659c977eb5106dcd83ea7765a._comment b/doc/bugs/importfeed__58___Enum.toEnum__123__Word8__125____58___tag___40__8217__41___is_outs/comment_6_9c6851e659c977eb5106dcd83ea7765a._comment new file mode 100644 index 0000000000..c11f288b81 --- /dev/null +++ b/doc/bugs/importfeed__58___Enum.toEnum__123__Word8__125____58___tag___40__8217__41___is_outs/comment_6_9c6851e659c977eb5106dcd83ea7765a._comment @@ -0,0 +1,18 @@ +[[!comment format=mdwn + username="joey" + subject="""comment 6""" + date="2025-09-29T14:45:50Z" + content=""" +Thanks for some really good detective work @ewen. + +Note that this only happens when git-annex is built with the OsPath build +flag. + +That seems to indicate that the problem is in +Utility.FileIO.openBinaryFile, +which is the only way that parseFeedFromFile' varies depending on that +build flag. + +Aha yes, the problem is that uses withOpenFileEncoding, which is +inappropriate for a binary file! +"""]]